package com.css.bjdt_report.executive.factory;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

import com.css.bjdt_report.executive.Executor;

public class ExecutorFactory {
	
	private static ConcurrentMap<String,Executor> registry = new ConcurrentHashMap<String,Executor>();

	public static Executor create(String className, boolean createNew){
		if(!registry.containsKey(className) || createNew){
			Executor executor = null;		 
			try {
				executor = (Executor) Class.forName(className).newInstance();
			} catch (Exception e) {
				
			}
			registry.put(className, executor);
		}
		return registry.get(className);
	}
}
